<template>
  <div class="">
    <ul class="list">
      <li
        v-for="item in list"
        :key="item.id"
        @click="$router.push('/detail/' + item.id)"
      >
        <img :src="'https://elm.cangdu.org/img/' + item.image_path" alt="" />
        <h5>{{ item.name }}</h5>
      </li>
    </ul>

    <van-tabbar route>
      <van-tabbar-item icon="home-o" to="/about">列表页</van-tabbar-item>
      <van-tabbar-item icon="search" to="/">搜索</van-tabbar-item>
      <van-tabbar-item icon="friends-o">标签</van-tabbar-item>
      <van-tabbar-item icon="setting-o">标签</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
import { getList } from "../utils/ele";
export default {
  setup(props, ctx) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({
      list: [],
    });
    let latitude = route.query.latitude;
    let longitude = route.query.longitude;
    getList({
      latitude,
      longitude,
    }).then((res) => {
      console.log(res);
      data.list = res;
    });

    return { ...toRefs(data) };
  },
};
</script>

<style lang="scss">
.list {
  li {
    display: flex;
    margin-top: 15px;
    img {
      width: 50px;
      height: 50px;
    }
  }
}
</style>
